import { IPublicModelPluginContext } from '@alilc/lowcode-types';
import { Button } from '@alifd/next';
import { saveSchema } from '@/services/mockService';

// 保存功能示例
const SaveSamplePlugin = (ctx: IPublicModelPluginContext) => {
  return {
    async init() {
      const { skeleton, hotkey, config, workspace } = ctx;
      console.log('111', ctx)

      skeleton.add({
        name: 'savePage',
        area: 'topArea',
        type: 'Widget',
        props: {
          align: 'right',
        },
        content: (
          <Button onClick={() => {
            saveSchema(ctx.editorWindow.resource?.id, ctx);
          }}>
            保存到本地
          </Button>
        ),
      });
    },
  };
}
SaveSamplePlugin.pluginName = 'SavePagePlugin';
SaveSamplePlugin.meta = {
  dependencies: [],
};
export default SaveSamplePlugin;